Skip to content

fix!: fix auth_methods module #313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jul 17, 2025
Merged

fix!: fix auth_methods module #313

merged 17 commits into from
Jul 17, 2025

Conversation

twishabansal
Copy link
Contributor

@twishabansal twishabansal commented Jul 15, 2025

This PR fixes the get_google_id_token and aget_google_id_token methods to get google id token from google cloud environments.

This code has been manually tested for the following cases:

  • Toolbox server is deployed on Cloud Run but the application is running locally.
  • Both the Toolbox server and the application and deployed on Cloud Run.

Fixes googleapis/genai-toolbox#806, #311, #310

For personal accounts on local environments, users can keep using the existing code.
For other cases,

Before:

from toolbox_core import ToolboxClient, auth_methods

# Replace with the Cloud Run service URL generated in the previous step.
URL = "https://cloud-run-url.app"

auth_token_provider = auth_methods.aget_google_id_token # can also use sync method

async with ToolboxClient(
    URL,
    client_headers={"Authorization": auth_token_provider},
) as toolbox:
   # use as needed

After

from toolbox_core import ToolboxClient, auth_methods

# Replace with the Cloud Run service URL generated in the previous step.
URL = "https://cloud-run-url.app"

auth_token_provider = auth_methods.aget_google_id_token(URL) # can also use sync method

async with ToolboxClient(
    URL,
    client_headers={"Authorization": auth_token_provider},
) as toolbox:
   # use as needed

@twishabansal twishabansal marked this pull request as ready for review July 15, 2025 08:17
@twishabansal twishabansal requested a review from a team as a code owner July 15, 2025 08:17
@twishabansal twishabansal changed the title fix: fix auth_methods module fix !: fix auth_methods module Jul 15, 2025
@twishabansal twishabansal changed the title fix !: fix auth_methods module fix!: fix auth_methods module Jul 15, 2025
anubhav756
anubhav756 previously approved these changes Jul 16, 2025
@twishabansal twishabansal requested a review from anubhav756 July 17, 2025 09:09
@twishabansal twishabansal merged commit 6cf6d6b into main Jul 17, 2025
20 checks passed
@release-please release-please bot mentioned this pull request Jul 17, 2025
twishabansal added a commit to googleapis/genai-toolbox that referenced this pull request Jul 18, 2025
github-actions bot pushed a commit to googleapis/genai-toolbox that referenced this pull request Jul 18, 2025
github-actions bot pushed a commit to renovate-bot/googleapis-_-genai-toolbox that referenced this pull request Jul 18, 2025
AnujJhunjhunwala pushed a commit to AnujJhunjhunwala/genai-toolbox that referenced this pull request Jul 18, 2025
AnujJhunjhunwala pushed a commit to AnujJhunjhunwala/genai-toolbox that referenced this pull request Jul 18, 2025
@twishabansal twishabansal deleted the fix-auth branch July 28, 2025 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when connecting to Cloud Run using service account
3 participants